﻿Public Class frmInicio

    Private Sub SalirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalir.Click
        Me.Close()
    End Sub

    Private Sub AcercaDeCircuitSoftToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAcercaDe.Click
        frmAbout.ShowDialog()
    End Sub

    Private Sub frmInicio_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If nombreUsuario <> "" Then
            If MessageBox.Show("¿Estás seguro que deseás salir?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = MsgBoxResult.No Then
                e.Cancel = True
            End If
        End If
        
    End Sub

    Private Sub EnviarOpiniónToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnviarOpinion.Click
        frmEnviarOpinion.ShowDialog()
    End Sub

    Private Sub frmInicio_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        consultarModulos()
        frmLoguin.ShowDialog()
        If nombreUsuario <> "" Then
            If rol = 1 Then 'SI es alumno
                btnDocente.Visible = False
            End If
        Else
            Me.Close()
        End If

    End Sub

    Private Sub btnPerfilDocente_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPerfilDocente.Click
        AdministrarAlumnos.Show()

    End Sub

    Private Sub DosResistenciasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSerie2R.Click
        circuito = "serie2r"
        frmCircuito2R.Text = "CircuitSoft - Circuito Eléctrico en Serie"
        frmCircuito2R.ShowDialog()
    End Sub

    Private Sub DosResistenciasToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnParalelo2R.Click
        circuito = "paralelo2r"
        frmCircuito2R.Text = "CircuitSoft - Circuito Eléctrico en Paralelo"
        frmCircuito2R.ShowDialog()
    End Sub

    Private Sub TresResistenciasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSerie3R.Click
        circuito = "serie3r"
        frmCircuito3R.Text = "CircuitSoft - Circuito Eléctrico en Serie"
        frmCircuito3R.ShowDialog()
    End Sub

    Private Sub TresResistenciasToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnParalelo3R.Click
        circuito = "paralelo3r"
        frmCircuito3R.Text = "Circuit Soft - Circuito Eléctrico en Paralelo"
        frmCircuito3R.ShowDialog()
    End Sub

    Private Sub TresResistenciasToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMixtos3R.Click
        circuito = "mixto3r"
        frmCircuito3R.Text = "Circuit Soft - Circuito Eléctrico Mixto"
        frmCircuito3R.ShowDialog()
    End Sub

    Private Sub CuatroResistenciasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMixtos4R.Click
        frmCircuito4R.Text = "Circuit Soft - Circuito Eléctrico Mixto"
        frmCircuito4R.ShowDialog()
    End Sub

    Private Sub WebQuestToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWebQuest.Click
        frmWebQuest.ShowDialog()
    End Sub

    Private Sub btnModulos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnModulos.Click
        frmModulos.ShowDialog()
    End Sub

    Private Sub consultarModulos()
        Dim tabla As DataTable
        tabla = obtenerTabla("modulo")

        'WEBQUEST
        If tabla(0)("habilitado") = True Then
            btnWebQuest.Enabled = True
        Else
            btnWebQuest.Enabled = False
            btnWebQuest.Visible = False
        End If

        'SERIE
        If tabla(1)("habilitado") = True Then
            btnSerie2R.Enabled = True
        Else
            btnSerie2R.Enabled = False
            btnSerie2R.Visible = False
        End If
        If tabla(2)("habilitado") = True Then
            btnSerie3R.Enabled = True
        Else
            btnSerie3R.Enabled = False
            btnSerie3R.Visible = False
        End If

        If (btnSerie2R.Enabled = False And btnSerie3R.Enabled = False) Then
            btnSerie.Visible = False
        Else
            btnSerie.Visible = True
        End If

        'PARALELO
        If tabla(3)("habilitado") = True Then
            btnParalelo2R.Enabled = True
        Else
            btnParalelo2R.Enabled = False
            btnParalelo2R.Visible = False
        End If
        If tabla(4)("habilitado") = True Then
            btnParalelo3R.Enabled = True
        Else
            btnParalelo3R.Enabled = False
            btnParalelo3R.Visible = False
        End If

        If (btnParalelo2R.Enabled = False And btnParalelo3R.Enabled = False) Then
            btnParalelo.Visible = False
        Else
            btnParalelo.Visible = True
        End If

        'MIXTOS
        If tabla(5)("habilitado") = True Then
            btnMixtos3R.Enabled = True
        Else
            btnMixtos3R.Enabled = False
            btnMixtos3R.Visible = False
        End If
        If tabla(6)("habilitado") = True Then
            btnMixtos4R.Enabled = True
        Else
            btnMixtos4R.Enabled = False
            btnMixtos4R.Visible = False
        End If

        If (btnMixtos3R.Enabled = False And btnMixtos4R.Enabled = False) Then
            btnMixtos.Visible = False
        Else
            btnMixtos.Visible = True
        End If
        
    End Sub

    Private Sub btnCerrarSesion_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCerrarSesion.Click
        nombreUsuario = ""
        rol = 0
        frmLoguin.txtUsuario.Text = ""
        frmLoguin.txtPassword.Text = ""
        frmLoguin.txtUsuario.Focus()
        frmLoguin.ShowDialog()
        If nombreUsuario = "" Then
            Me.Close()
        End If
    End Sub

    Private Sub ObjetivosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnObjetivos.Click
        Form1.ShowDialog()
    End Sub
End Class
